
# 获得当前程序的顶层目录: 此处后面不能跟空格，否则不能衔接 Makefile.build
TOPDIR := $(shell pwd)
export TOPDIR                       # 输出顶层目录
# $(warning TOPDIR is $(TOPDIR))

# 输出目录
OUTDIR := $(TOPDIR)/build
export OUTDIR

# 静音输出
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
export KBUILD_VERBOSE

# 调试版本
ifeq ("$(origin D)", "command line")
KBUILD_DEBUG = $(D)
endif
ifndef KBUILD_DEBUG
KBUILD_DEBUG = 0
endif
export KBUILD_DEBUG


submod-y += lib/
submod-y += src/
$(warning submod is $(submod-y))

# 非实体目标
.PHONY:all clean $(submod-y)

all: $(submod-y)

# 
# 通过 Makefile.build 引入 Makefile
#
$(submod-y): 
	$(if $(KBUILD_VERBOSE:1=),@) make -C $@ -f $(TOPDIR)/mk/extapp.mk


clean:
	@find ./ -name '*.o' | xargs rm -rf 
	@rm -rf  $(OUTDIR) 
	@rm -rf lib/libdynamic.so  lib/libstatic.a
	@find ./ -name '*.o.d' | xargs rm -rf 


distclean:
	@find ./ -name '*.o' | xargs rm -rf 
	@find ./ -name '*.o.d' | xargs rm -rf 
	@find ./ -name '*.a' | xargs rm -rf 
	@find ./ -name '*.so' | xargs rm -rf 
